package _021_10_6

import (
	"sort"
	"strconv"
	"strings"
)

type timeInfo struct {
	hour   int
	minute int
}
type timeArr []timeInfo

func (t timeArr) Len() int {
	return len(t)
}

func (t timeArr) Less(i, j int) bool {
	if t[i].hour <= t[j].hour {
		if t[i].hour == t[j].hour {
			if t[i].minute <= t[i].minute {
				return true
			} else {
				return false
			}
		}
		return true
	}
	return false
}

func (t timeArr) Swap(i, j int) {
	temp := t[i]
	t[i] = t[j]
	t[j] = temp
}

func sortTime(times []string) {

	var arr timeArr

	for i := 0; i < len(times); i++ {
		timeItm := strings.Split(times[i], ":")
		hour, _ := strconv.Atoi(timeItm[0])
		minute, _ := strconv.Atoi(timeItm[1])
		arr = append(arr, timeInfo{hour: hour, minute: minute})
	}
	sort.Sort(arr)
}
